﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WA.Core.DomainModel;

namespace WA.Utility.EntityHelpers
{
    public class InvoiceHelper
    {
        public static OutputInvoice GetRandomOutputInvoice()
        {
            OutputInvoice outputInvoice = new OutputInvoice();
            SetInvoiceData(outputInvoice);
            outputInvoice.InternalInvoiceAmount = Decimal.Parse("100");
            outputInvoice.OtherDeliveryInvoicesVatReleased = Decimal.Parse("0");
            outputInvoice.ExportInvoiceAmount = Decimal.Parse("200");
            return outputInvoice;            
        }

        public static EntryInvoice GetRandomEntryInvoice()
        {
            Random rand = new Random();
            EntryInvoice entryInvoice = new EntryInvoice();
            SetInvoiceData(entryInvoice);
            entryInvoice.LumpSum = Decimal.Parse("10");
            entryInvoice.VatThatCanBeDeducted = Decimal.Parse("10");
            entryInvoice.VatThatCanNotBeDeducted = Decimal.Parse("0");
            entryInvoice.AmountWithoutVat = entryInvoice.Total - entryInvoice.SubTotal;
            return entryInvoice;
        }

        private static void SetInvoiceData(Invoice inv)
        {
            Random rand = new Random();
            inv.Company = CompanyHelper.GetRandomCompanyInstance();
            inv.Partner = PartnerHelper.GetRandomPartnerInstance();
            inv.InvoiceNumber = "rand" + DateTime.UtcNow.Ticks.ToString();
            inv.ReleaseDate = DateTime.Now;
            inv.ReleaseYear = DateTime.Now.Year;
            inv.SubTotal = (Decimal)(rand.NextDouble() * rand.Next(100, 10000));
            inv.Total = (Decimal)((double)inv.SubTotal * 1.17);
            inv.Vat = inv.Total - inv.SubTotal;            
        }
    }
}
